<?php
class listar extends controller
{
	private $t = null;
	public function __construct(tpl & $plantilla)
	{
		$plantilla->set('title','Listando los alimentos');
		$this->t = & $plantilla;
	}
	public function verduras()
	{
		$this->t->parse('lista');
		require 'require/verduras.php';
		return $this->t->render('lista');
	}
	public function verdurasJSON()
	{
		/*$verduras = DB::select('verduras',
			array('verduraid AS id',
			'nombre','tmb','fot','minerales','vitaminas','proteinas','calorias',
			'prop','linkC','riesgos','linkD'));
		$verduras->execute();
		echo json_encode( $verduras->fetchAll(DB::FETCH_ASSOC));
		die();/**/
		$columnas = array('verduraid AS id',
			'nombre','tmb','fot'/*,
			'minerales','vitaminas','proteinas','calorias',
			'prop','linkA','riesgos','linkB'/**/
			);
		$header  = $columnas;
		//array_shift($header);
		//unset($header[0]);
		$header[0] = null;
		$frutas = DB::select('verduras',$columnas	);
		$frutas->execute();
		
		echo json_encode(array(
							'header' => $header ,
							'data' => $frutas->fetchAll(DB::FETCH_NUM)
							)
						);
		die();
	}
	public function frutasJSON()
	{
		$columnas = array('frutaid AS id',
			'nombre','tmb','fot'/*,
			'minerales','vitaminas','proteinas','calorias',
			'prop','linkA','riesgos','linkB'/**/
			);
		$header  = $columnas;
		//array_shift($header);
		//unset($header[0]);
		$header[0] = null;
		$frutas = DB::select('frutas',$columnas	);
		$frutas->execute();
		
		echo json_encode(array(
							'header' => $header ,
							'data' => $frutas->fetchAll(DB::FETCH_NUM)
							)
						);
		die();
	}
	public function condimentosJSON()
	{
		$columnas = array('condiment_id	 AS id',
			'nombre','tmb','fot'/*,
			'minerales','vitaminas','proteinas','calorias',
			'prop','linkA','riesgos','linkB'/**/
			);
		$header  = $columnas;
		//array_shift($header);
		//unset($header[0]);
		$header[0] = null;
		$frutas = DB::select('condimentos',$columnas	);
		$frutas->execute();
		
		echo json_encode(array(
							'header' => $header ,
							'data' => $frutas->fetchAll(DB::FETCH_NUM)
							)
						);
		die();
	}
	public function getDefault()
	{
		$this->t->parse('listar');
		require 'require/alimentos.php';
		return $this->t->render('listar');
	}
}
